package com.itheima.homework;

import java.text.DateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class demo04 {
    public static void main(String[] args) {
        LocalDateTime ldt1= LocalDateTime.now();
        LocalDate ldt2 = LocalDate.now();
        LocalTime ldt3 = LocalTime.now();
        String ss = "2024-11-15 21:41:18";
        String s5 = "2024-11-15";
        DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String format = ldt1.format(dtf1);
        String format2 = dtf1.format(ldt1);
        System.out.println(format2);
        System.out.println(format);
        String format1 = dtf1.format(ldt1);
        LocalDateTime parse = LocalDateTime.parse(ss, dtf1);
        String s2 = dtf1.format(parse);
        System.out.println(parse);
        System.out.println(s2);

        LocalDate parse1 = LocalDate.parse(s5, dtf2);
        System.out.println(parse1);


    }
}
